<template>
  <div class="myDiv">
    <!-- 退役士兵 -->
    <el-card class="box-card secordCard" shadow="never">
      <div slot="header" class="clearfix">
        <span>退役士兵信息</span>
        <!-- <el-button style="float: right; padding: 3px 0" type="text">收起</el-button> -->
      </div>
      <div>
        <el-form ref="form" :model="form" :rules="rules" class="formWidth" label-width="140px">
        <el-row :gutter="10">
          <el-col :span="8">
            <el-form-item label="入伍时间" prop="enlistedDate">
              <el-date-picker clearable size="small"
                v-model="form.enlistedDate"
                type="date"
                value-format="yyyy-MM-dd"
                placeholder="选择入伍时间">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="退役时间" prop="retirementDate">
              <el-date-picker clearable size="small"
                v-model="form.retirementDate"
                type="date"
                value-format="yyyy-MM-dd"
                placeholder="选择退役时间">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="入伍时户籍性质" prop="enlistedCensusType">
              <el-select v-model="form.enlistedCensusType" placeholder="请选择入伍时户籍性质">
                <el-option
                  v-for="dict in enlistedCensusTypeOptions"
                  :key="dict.dictValue"
                  :label="dict.dictLabel"
                  :value="parseInt(dict.dictValue)"
                ></el-option>
              </el-select>
            </el-form-item>
           </el-col>
           <el-col :span="8">
            <el-form-item label="原部队代号" prop="originalUnitCode">
              <el-input v-model="form.originalUnitCode" placeholder="请输入原部队代号" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="原衔级" prop="originalRank">
              <el-select v-model="form.originalRank" placeholder="请选择原衔级">
                <el-option
                  v-for="dict in originalRankOptions"
                  :key="dict.dictValue"
                  :label="dict.dictLabel"
                  :value="dict.dictValue"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="退役证件号码" prop="retirementCertificateCode">
              <el-input v-model="form.retirementCertificateCode" placeholder="请输入退役证件号码" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="立功受奖情况 " prop="honour">
              <el-select v-model="form.honour" placeholder="请选择立功受奖情况 ">
                <el-option
                  v-for="dict in honourOptions"
                  :key="dict.dictValue"
                  :label="dict.dictLabel"
                  :value="parseInt(dict.dictValue)"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="安置方式" prop="arrangeWay">
              <el-input v-model="form.arrangeWay" placeholder="请输入安置方式" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="安置日期" prop="arrangeDate">
              <el-date-picker clearable size="small"
                v-model="form.arrangeDate"
                type="date"
                value-format="yyyy-MM-dd"
                placeholder="选择安置日期">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="安置地" prop="arrangePlace">
              <el-input v-model="form.arrangePlace" placeholder="请输入安置地 省市县/区" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="安置单位名称" prop="arrangeUnit">
              <el-input v-model="form.arrangeUnit" placeholder="请输入安置单位名称" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="安置单位性质" prop="arrangeUnitType">
              <el-select v-model="form.arrangeUnitType" placeholder="请选择安置单位性质">
                <el-option
                  v-for="dict in arrangeUnitTypeOptions"
                  :key="dict.dictValue"
                  :label="dict.dictLabel"
                  :value="parseInt(dict.dictValue)"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="政府教育培训" prop="attendTraining">
              <el-select v-model="form.attendTraining" placeholder="请选择政府教育培训">
                <el-option
                  v-for="dict in attendTrainingOptions"
                  :key="dict.dictValue"
                  :label="dict.dictLabel"
                  :value="parseInt(dict.dictValue)"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="现就业状况" prop="employmentSituation">
              <el-select v-model="form.employmentSituation" placeholder="请选择现就业状况">
                <el-option
                  v-for="dict in employmentSituationOptions"
                  :key="dict.dictValue"
                  :label="dict.dictLabel"
                  :value="parseInt(dict.dictValue)"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
       </el-form>
      </div>
    </el-card>
  </div>
</template>

<script>
export default {
  name: "retiredCard",
  data(){
    return {
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        enlistedDate: [
          { required: true, message: "入伍时间不能为空", trigger: "blur" }
        ],
        retirementDate: [
          { required: true, message: "退役时间不能为空", trigger: "blur" }
        ],
      },
       // 入伍时户籍性质字典
      enlistedCensusTypeOptions: [],
      // 原衔级字典
      originalRankOptions: [],
      // 立功受奖情况 字典
      honourOptions: [],
      // 安置方式字典
      arrangeWayOptions: [],
      // 安置单位性质字典
      arrangeUnitTypeOptions: [],
      // 参加政府组织的教育培训状况1字典
      attendTrainingOptions: [],
      // 现就业状况字典
      employmentSituationOptions: [],
    }
  },
  props:{
    soldierId: String,
  },
  mounted(){
    this.form.soldierId = this.soldierId
  },
   created() {
    this.getDicts("enlisted_census_type").then(response => {
      this.enlistedCensusTypeOptions = response.data;
    });
    this.getDicts("original_rank").then(response => {
      this.originalRankOptions = response.data;
    });
    this.getDicts("honour").then(response => {
      this.honourOptions = response.data;
    });
    this.getDicts("arrange_way").then(response => {
      this.arrangeWayOptions = response.data;
    });
    this.getDicts("arrange_property").then(response => {
      this.arrangeUnitTypeOptions = response.data;
    });
    this.getDicts("yes_or_no").then(response => {
      this.attendTrainingOptions = response.data;
    });
    this.getDicts("employment_situation").then(response => {
      this.employmentSituationOptions = response.data;
    });
  },
  methods:{
     validateForm(){
      return new Promise((resolve , reject) => {
        this.$refs.form.validate(valid => {
          if (valid) {
            resolve();
          } else reject();
        });
      })
     }
  },
}
</script>
<style lang="scss" scoped>
.box-card{
  margin-bottom: 16px;
}
::v-deep .secordCard .el-form-item__content {
   height: 36px;
}
</style>